<?php


namespace plugin\coupon\app\admin\logic;


use app\common\logic\BaseLogic;
use plugin\coupon\app\model\CouponReceiveLog;

class CouponReceiveLogLogic extends BaseLogic
{
    public function __construct()
    {
        $this->model =new CouponReceiveLog();
    }

    public function getCountByUserId($uid)
    {
        return $this->model->where([
            'user_id' => $uid,
            'status' => CouponReceiveLog::STATUS_NO_USED,
        ])
            ->with([
                'coupon',
                'coupongoods',
            ])
            ->count();
    }

    public function findCoupon($receiveId)
    {
        $list = $this->model->where([
            'id' => $receiveId,
        ])
            ->with([
                'coupon',
                'coupongoods',
            ])
            ->find()->toArray();
        return $list;
    }
}